﻿#include "startwindow.h"
#include "ui_startwindow.h"
#include "loading1.h"
#include "qpixmap"
#include <QRandomGenerator>
#include <qpainter.h>
#include <QMainWindow>
#include "loading2.h"
startWindow::startWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::startwindowClass)
{
    ui->setupUi(this);
    // 设置启动窗口大小
    setFixedSize(1100, 800);

    // 设置背景图，使用随机数选取1/10
    int num = QRandomGenerator::global()->bounded(10);
    QString path = QString(":/images/background-%1.png").arg(num + 1);
    m_bkImage.load(path);
    update();

    // 第一个游戏入口，
    connect(ui->pushButton, &QPushButton::clicked, this, [=]() {
        Loading1* load1 = new Loading1;
        load1->show();
        close();
        });

    // 第二个游戏入口
    connect(ui->pushButton_2, &QPushButton::clicked, this, [=]() {
        Loading2* load2 = new Loading2;
        load2->show();
        close();
        });

}

// 绘图事件，背景图
void startWindow::paintEvent(QPaintEvent* ev){
    QPainter p(this);
    p.drawPixmap(rect(), m_bkImage);
  
    
}

startWindow::~startWindow()
{}
